<%-- 
    Document   : wrapper
    Created on : 5-apr-2013, 9.25.55
    Author     : Giuseppe
--%>
<%@page import="ejb.Messaggio"%>
<%@page import="java.util.List"%>
<?xml version="1.0" encoding="UTF-8"?>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@page import="ejb.Utente"%>

<html xml:lang="it" lang="it">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="funzioni_javascript.js"></script>
<title>Portale VideoGames</title>

<!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<link rel="stylesheet" type="text/css" href="./bootstrap/css/bootstrap.css">



<script src="./bootstrap/js/jquery.min.js"></script>
<script src="./bootstrap/js/bootstrap.js"></script>



<!-- or the full Bootstrap JS if you want other features
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap.js"></script> -->

<style type="text/css">

*, html {
	margin: 0;padding: 0;
}

body {
	background: #f9f9f9;
}
.navbar-search .search-query {
    padding-left: 29px !important;
}/*lascia spazio per l'icona'*/
.navbar-search .icon-search {
    position: absolute;
    top: 7px;
    left: 11px;
}/* spazio per inserire il simbolo di ricerca*/
#wrapper {
	width: 940px;
	min-height: 500px;
	margin: 50px auto;
	padding: 25px;
	border-radius: 5px;
	background: #fff;
	box-shadow: 0 0 1px 1px #eee;
}

	/* dropdown
	------------------------------------------------------- */

.dropdown-menu {
	display: none;
	background: #f9f9f9;
	border: 1px solid #ddd;
	border-top: none;
	z-index: 9;
}
.dropdown-menu:hover {
	cursor: pointer;
        display: block;
}
.dropdown-menu li a {
	font-weight: normal;
}
ul.nav li.dropdown:hover ul.dropdown-menu{
    display: block;
}
.pull-right, [class*="span"] .pull-right {
float: right;
}
.pull-left, [class*="span"] .pull-left {
float: left;
}
.container { margin-left: 0px; }
.navbar .nav > li > a {
padding: 10px 11px 10px;
}

</style>

</head>
<div id="wrapper">

          <div id="navbar-example" class="navbar navbar-static">
            <div class="navbar-inner" style="padding-left:0px;height: 55px;padding-right: 2px">
              <div class="container">
                <ul class="nav" >
                        <li>
                            <a href="Controller?button=home">
                                <p>
                                    <span><img src="./img/logo.gif" height="35" width="50"><b>GameWorld</b></span>
                                </p>
                            </a>
                        </li>
                        <li class="divider-vertical" ></li>
	             	<li>
                            <a href="Controller?button=visualizzaRecNot&platform=PC&type=both">
                                <p onmouseover="highlightLink(this)" onmouseout="unhighlightLink(this)" style="padding-top: 7px">
                                    <span><b>Pc</b></span>
                                </p>
                            </a>
			</li>
                        
                        <li class="divider-vertical" ></li>

                        <li class="dropdown">
			  <a class="dropdown-toggle" href="#" data-toggle="dropdown">
                            <p onmouseover="highlightLink(this)" onmouseout="unhighlightLink(this)" style="padding-top: 7px">
                                 <span><b>Sony</b></span>
                            </p>
                          </a>
                          <ul class="dropdown-menu">
                              <li><a href="Controller?button=visualizzaRecNot&platform=SONY&type=both">Tutte le console</a></li>
			      <li><a href="Controller?button=visualizzaRecNot&platform=PS3&type=both">Playstation 3</a></li>
			      <li><a href="Controller?button=visualizzaRecNot&platform=PSVITA&type=both">Playstation Vita</a></li>
			   </ul>
			 </li>
                  
                    <li class="divider-vertical" ></li>
                         
                    <li class="dropdown">
                    <a class="dropdown-toggle" href="#" data-toggle="dropdown">
                        <p onmouseover="highlightLink(this)" onmouseout="unhighlightLink(this)" style="padding-top: 7px">
                                 <span><b>Nintendo</b></span>
                         </p>
                    <ul class="sub-menu dropdown-menu">
                      <li><a href="Controller?button=visualizzaRecNot&platform=NINTENDO&type=both">Tutte le console</a></li>
                      <li><a href="Controller?button=visualizzaRecNot&platform=3DS&type=both">Nintendo 3ds</a></li>
                      <li><a href="Controller?button=visualizzaRecNot&platform=DS&type=both">Nintendo ds</a></li>
                      <li><a href="Controller?button=visualizzaRecNot&platform=WII&type=both">Wii</a></li>
                      <li><a href="Controller?button=visualizzaRecNot&platform=WIIU&type=both">WiiU</a></li>
                    </ul>
                  </li>
                
               <li class="divider-vertical" ></li>   
                  
               <li>
                    <a href="Controller?button=visualizzaRecNot&platform=ANDROID&type=both">
                        <p onmouseover="highlightLink(this)" onmouseout="unhighlightLink(this)" style="padding-top: 7px">
                             <span><b>Android</b></span>
                         </p>
                    </a>
               </li>
               
               <li class="divider-vertical" ></li>
               
               <li>
                    <a href="Controller?button=visualizzaRecNot&platform=APPLE&type=both">
                        <p onmouseover="highlightLink(this)" onmouseout="unhighlightLink(this)" style="padding-top: 7px">
                                 <span><b>Apple</b></span>
                         </p>
                    </a>
               </li>
               
               <li class="divider-vertical" ></li>
               
               <li>
		     <a href="Controller?button=visualizzaRecNot&platform=XBOX360&type=both">
                         <p onmouseover="highlightLink(this)" onmouseout="unhighlightLink(this)" style="padding-top: 7px">
                                 <span><b>XBox 360</b></span>
                         </p>
                     </a>
               </li>
	</ul>
                  
        
	<%
                                           
        Utente utente = (Utente)session.getAttribute("utente");
        List<Messaggio> messDaLeggere = (List<Messaggio>)session.getAttribute("messDaleggere");
        if(utente!=null){
            if(utente.getTipo().equals("u")){
        %>
             <ul class="nav pull-right">
	          <li class="divider-vertical"></li>
	          <li class="dropdown">
                  <% if(utente.getUsername().length()>11){
                        String username = utente.getUsername().substring(0,11) +"..";
                  %>
                  <a class="dropdown-toggle" href="#" data-toggle="dropdown">
                      <p style="padding-top: 7px">
                          <b><%=username%></b>
                          <b class="caret"></b>
                          <span style="padding-left: 5px"><b>U</b></span>
                      </p>
                  </a>
		  <%}else{%>
                  <a class="dropdown-toggle" href="#" data-toggle="dropdown">
                      <p style="padding-top: 7px">
                          <b><%=utente.getUsername()%></b>
                          <b class="caret"></b>
                          <span style="padding-left: 5px"><b>U</b></span>
                      </p>
                  </a>
                  <%}%>
                  
                  <ul class="sub-menu dropdown-menu">
                        <li><a href="Controller?button=visualizzaModificaCancellaVideogioco">Visualizza Videogiochi</a></li>
                        <li><a href="Controller?button=vendiArticolo">Vendi Articolo</a></li>
                        <li><a href="Controller?button=visualizzaArticoli&amp;typeView=All">Guarda Articoli </a></li>
                        
                        <% if (utente.getPassword() != null) {%> 
                                <li><a href="Controller?button=modificaProfiloAus">Modifica Profilo</a></li>
                                <li><a href="Controller?button=logout">Logout</a></li>
                        <%} else {%>    
                        
                           <script type="text/javascript" src="facebook.js"></script> 
                           
                           <% if (utente.getSocial().equals("fb")) {%>
                                 <li><a href="Controller?button=logout" onclick="logoutFB()">Logout</a></li>
                           <% }else {%>
                                <li><a href="Controller?button=logout" >Logout</a></li>
                           <% }
                            }%>
                            
                </ul>
                </li>
            </ul>
            
            <%}else if(utente.getTipo().equals("r")){%>
                              
            <ul class="nav pull-right">
                <li class="divider-vertical"></li>
                <li class="dropdown">
                      <% if(utente.getUsername().length()>11){
                        String username = utente.getUsername().substring(0,11) +"..";
                  %>
                  <a class="dropdown-toggle" href="#" data-toggle="dropdown">
                      <p style="padding-top: 7px">
                          <b><%=username%></b>
                          <b class="caret"></b>
                          <span style="padding-left: 5px"><b>R</b></span>
                      </p>
                  </a>
		  <%}else{%>
                  <a class="dropdown-toggle" href="#" data-toggle="dropdown">
                      <p style="padding-top: 7px">
                          <b><%=utente.getUsername()%></b>
                          <b class="caret"></b>
                          <span style="padding-left: 5px"><b>R</b></span>
                      </p>
                  </a>
                  <%}%>
                      <ul class="sub-menu dropdown-menu">
                         <li><a href="Controller?button=visualizzaModificaCancellaVideogioco">Visualizza Videogiochi</a></li>
                         <li><a href="Controller?button=aggiungiNotiziaAus">Aggiungi Notizia</a></li>
                         <li><a href="Controller?button=aggiungiRecensioneInternaAus">Aggiungi Recensione Interna</a></li>
                         <li><a href="Controller?button=aggiungiRecensioneEsternaAus">Aggiungi Recensione Esterna</a></li>
                         <li><a href="Controller?button=modificaNotiziaAus">Gestisci Notizie</a></li>
                         <li><a href="Controller?button=modificaRecensioneInternaAus">Gestisci Recensioni Interne</a></li>
                         <li><a href="Controller?button=modificaRecensioneEsternaAus">Gestisci Recensioni Esterne</a></li>
                         <li><a href="Controller?button=modificaProfiloAus">Modifica Profilo</a></li>
                         <li><a href="Controller?button=logout">Logout</a></li>

                      </ul>
                 </li>
              </ul>
           
           <%}else{ %>

           <ul class="nav pull-right">
                <li class="divider-vertical"></li>
                <li class="dropdown">
                     <% if(utente.getUsername().length()>11){
                        String username = utente.getUsername().substring(0,11) +"..";
                  %>
                  <a class="dropdown-toggle" href="#" data-toggle="dropdown">
                      <p style="padding-top: 7px">
                          <b><%=username%></b>
                          <b class="caret"></b>
                          <span style="padding-left: 5px"><b>A</b></span>
                      </p>
                  </a>
		  <%}else{%>
                  <a class="dropdown-toggle" href="#" data-toggle="dropdown">
                      <p style="padding-top: 7px">
                          <b><%=utente.getUsername()%></b>
                          <b class="caret"></b>
                          <span style="padding-left: 5px"><b>A</b></span>
                      </p>
                  </a>
                  <%}%>

                      <ul class="sub-menu dropdown-menu">
                        <li><a href="Controller?button=aggiungiRecensoreAus">Aggiungi Recensore</a></li>
                        <li><a href="Controller?button=aggiungiPiattaformaAus">Aggiungi Piattaforma</a></li>
                        <li><a href="Controller?button=aggiungiVideogiocoAus">Aggiungi Videogioco</a></li>
                        <li><a href="Controller?button=articoloNuovo">Aggiungi Articolo Nuovo</a></li>
                        <li><a href="Controller?button=modificaNotiziaAus">Gestisci Notizie</a></li> 
                        <li><a href="Controller?button=visualizzaRecensioniInterne">Gestisci Recensioni Interne</a></li> 
                        <li><a href="Controller?button=visualizzaRecensioniEsterne">Gestisci Recensioni Esterne</a></li>
                        <li><a href="Controller?button=modificaCancellaArtUsati&amp;confirm=n">Gestisci Articoli Usati</a></li>
                        <li><a href="Controller?button=modificaCancellaArtNuovi">Gestisci Articoli Nuovi</a></li>
                        <li><a href="Controller?button=visualizzaModificaCancellaVideogioco">Gestisci Videogiochi</a></li>
                        <li><a href="Controller?button=visualizzaUtenti">Gestisci Utenti</a></li>
                        <li><a href="Controller?button=modificaProfiloAus">Modifica Profilo</a></li>
                        <li><a href="Controller?button=logout">Logout</a></li>

                      </ul>
                </li>
          </ul>

          <%}%>
          
          <ul class="nav pull-right">
               <li class="divider-vertical" ></li>
              <%
          String nomeMittente;Utente utMittente;
          List<Messaggio> mailboxRicevuti = (List<Messaggio>)session.getAttribute("mailboxRicevuti");
          if(!mailboxRicevuti.isEmpty()){%>
          
              <li class="dropdown">
                <%if(messDaLeggere.size()!=0){%>
                    <a class="dropdown-toggle" href="Controller?button=visualizzaMailboxRicevuti" data-toggle="dropdown">
                        <p style="padding-top: 9px">
                            <span><b><%=messDaLeggere.size()%></b></span><img src="./img/iconMessages.png" height="25" width="25">
                        </p>
                    </a>
                <%}else{%>
                    <a class="dropdown-toggle" href="Controller?button=visualizzaMailboxRicevuti" data-toggle="dropdown">
                        <p style="padding-top: 9px">
                            <span><b></b></span><img src="./img/iconMessages.png" height="25" width="25">
                        </p>
                    </a>
                  <%}%>
                    <ul class="sub-menu dropdown-menu">
                    <li class="thumbnail">
                            <a href="Controller?button=scriviMessaggio">
                                <p height="9" align="right"><b>Scrivi Messaggio</b></p>
                            </a>
                    </li>
         <%
             for(Messaggio m : mailboxRicevuti){
                 utMittente=m.getMittente();
                 nomeMittente = utMittente.getNome() + " " + utMittente.getCognome();
                          
                 //Se il messaggio Ã¨ stato letto non sarÃ  evidenziato
                 if(!messDaLeggere.contains(m)){%>
                    <li class="thumbnail" align="left">
                            <a href="Controller?button=visualizzaMessaggio&amp;received=s&messageCode=<%=m.getId()%>">
                                <img height="25" width="25" src="./img/icona_mail.png" alt="" style="padding-left:10px;padding-top:5px"><span style="padding-left:10px"><b>From: </b><%=nomeMittente%></span>
                            </a>
                        </li>
                  <%}else{%>
                        <li class="thumbnail" align="left" style="background-color: #eee">
                            <a href="Controller?button=visualizzaMessaggio&amp;received=s&messageCode=<%=m.getId()%>">
                                <img height="25" width="25" src="./img/icona_mail.png" alt="" style="padding-left:10px;padding-top:5px"><span style="padding-left:10px"><b>From: </b><%=nomeMittente%></span>
                            </a>
                        </li>
                   <%}
                    }
                   }
                   else{%>
                   
                   <li class="dropdown">
                        <a class="dropdown-toggle" href="Controller?button=visualizzaMailboxRicevuti" data-toggle="dropdown"><span><b></b></span><img src="./img/iconMessages.png" height="25" width="25"></a>
                        <ul class="sub-menu dropdown-menu">
                            <li class="thumbnail">
                            <a href="Controller?button=scriviMessaggio">
                                <p height="9" align="right"><b>Scrivi Messaggio</b></p>
                            </a>
                            </li>
                            <li class="thumbnail"><p><b>Nessun messaggio presente.</b></p></li>
                        </ul>      
                   <%}%>  
              </ul>
          </ul>
          
          <%}else{%>
                    
                    <script type="text/javascript" src="facebook.js"></script> 

                    <ul class="nav pull-right">

                        <li class="divider-vertical" ></li>
                        <li class="dropdown" >
                            <a class="dropdown-toggle" href="#" data-toggle="dropdown">
                                <p style="padding-top: 7px">
                                    <b>Accedi</b> <b class="caret"></b>
                                </p>
                            </a>
                            <ul class="sub-menu dropdown-menu" style="width:215px">
                                <form action="Controller" method="POST" onSubmit="return displayResultLogin(this)"> 
                                        
                                    <br>
                                    <li><p align="left" style="padding-left: 12px;height: 12px"><span><b>Username</b></span></p></li>
                                    <li><p align="left" style="padding-left: 10px;height: 14px"><input type="text"  placeholder="Username"  name="username" style="width:180px;"></p></li>
                                    <br>
                                    <li><p align="left" style="padding-left: 12px;height: 12px"><span><b>Password</b></span></p></li>
                                    <li><p align="left" style="padding-left: 10px;height: 14px"><input type="password" placeholder="Password"  name="pwd" style="width:180px;"></p></li>
                                    <br>
                                    <li><p align="left" style="padding-left: 10px;height: 50px"><button  class="btn success" type="submit" value="login" name="button" style="width:192px"><b>Login</b></button></p></li>
                                    
                                    <p align="left" style="padding-left:10px"><span><b>Accedi tramite</b></span>
                                        <img  src="./img/google.png" height="25" width="25" style="padding-left: 10px;padding-right: 10px" onClick="loginGoogle();">
                                        <img  src="./img/facebook.png" height="25" width="25" onClick="loginFB();"> 
                                    </p>
                                    <p align="left" style="padding-left:25px">
                                        
                                    </p>
                                    
                                    <li><label>___________________________</label></li>
                                    <li><label id="errore" style="color: red;"></label> </li>

                                    <ul class="nav pull-left"  style="padding-left: 10px"> <a href="Controller?button=registrati"><button  class="btn success" type="button" style="width:192px"><b>Registrati</b></button></a> </ul>
                                </form>

                            </ul>
                        </li>
                    </ul>
                    <ul class="nav pull-right">
                        <li>
                            <a>
                            <p style="padding-top: 7px">
                                <span><b></b></span> <img src="./img/iconMessages.png" height="25" width="25">
                            </p>
                            </a>
                        </li>
                    </ul>

                            <% }
                            %>


              </div>
            </div>
          </div> <!-- fine topbar parte condivisa da tutte le pagine-->

